home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Unix / satan-1.1.1 / perl / run-satan.pl < prev    next >
Text File  |  1995-04-10  |  1KB  |  59 lines

  1. require 'perl/satan-data.pl';
  2. require 'perl/misc.pl';
  3. require 'perl/getfqdn.pl';
  4. require 'perl/get_host.pl';
  5. require 'perl/suser.pl';
  6.  
  7. sub run_satan {
  8.     local($primaries) = @_;
  9.     local($target);
  10.  
  11.     #
  12.     # Don't die silently when tools cannot be run with sufficient privilege.
  13.     #
  14.     die "SATAN needs root privileges for data collection.\n" if $>;
  15.  
  16.     #
  17.     # Clear the table with alive hosts.
  18.     #
  19.     %host_is_alive = ();
  20.  
  21.     #
  22.     # Set up a list of primary target hosts.
  23.     #
  24.     die "no primary target was specified" if $primaries eq "";
  25.     for $primary_target (split(/\s+/, $primaries)) {
  26.         #
  27.         # Jump hoops to get at the official host name in case foo.com is
  28.         # in reality called bar.foo.com.
  29.         #
  30.         if ($primary_target =~ /^[a-zA-Z]+.*|^\d+\.\d+\.\d+\.\d+$/) {
  31.             $primary_target = $target
  32.                 if ($target = &getfqdn(&get_host_name(
  33.                     &get_host_addr($primary_target))));
  34.         }
  35.  
  36.         # schedule probe assignments...
  37.         &add_primary_target($primary_target, 0);
  38.     }
  39.     #
  40.     # In case we must do something special with primary target hosts.
  41.     #
  42.     &fix_primary_targets();
  43.  
  44.     #
  45.     # Switch control between the data collection engine and the
  46.     # inference engine until both run out of new ideas. Checkpoint
  47.     # after each iteration.
  48.     #
  49.     while(sizeof(*new_targets)||sizeof(*new_todos)||sizeof(*new_facts)) {
  50.         &process_targets();
  51.         &process_todos();
  52.         &process_facts();
  53.         &save_satan_data();
  54.     }
  55.     &update_status("SATAN run completed");
  56. }
  57.  
  58. 1;
  59.